package com.zzyl;

import cn.hutool.http.HttpResponse;
import cn.hutool.http.HttpUtil;
import cn.hutool.http.Method;
import org.junit.jupiter.api.Test;

import java.util.HashMap;
import java.util.Map;

public class Hutooltest {

    @Test
    public void test1(){
        String str = HttpUtil.get("https://www.baidu.com");
        System.out.println(str);
    }


    @Test
    public void test2(){
        Map<String, Object> paramMap = new HashMap<>();
        paramMap.put("pageNum",1);
        paramMap.put("pageSize",10);
        String result=HttpUtil.get("http://localhost:8080/serve/project/list", paramMap);
        System.out.println(result);
    }


    @Test
    public void testCreateRequest() {
        // 构建查询参数
        Map<String,Object> paramMap = new HashMap<>();
        paramMap.put("pageNum", 1);
        paramMap.put("pageSize", 5);
        // 分页查询护理项目
        HttpResponse response = HttpUtil.createRequest(Method.GET, "http://localhost:8080/serve/project/list")
                .header("Authorization", "Bearer eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX2tleSI6IjBiMjBkNTFmLTU1NjYtNDZiMi05NmU5LWNhNzRjYjBlZDQ0NCJ9.QZvI4eQ3kyj_CiV8x_VVUpZTVGVi9DIjMSbij7xtkMcz573nxTFu8ChiKz6JKpzQO25wPPtsDjhRFal5t7hPWA")
                .form(paramMap)
                .execute();
        if(response.isOk()){
            System.out.println(response.body());
        }
    }
}
